<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			/* function Worker(name, salary, hour) {
				this.name = name;
				this.salary = salary;
				this.hour = hour;
			} */
			class Worker {
				name;
				age;
				#salary; //私有属性
				static hour = 8; //静态属性
				constructor(name, age, salary) {
					this.name = name;
					this.age = age;
					this.#salary = salary;
				}

				getSalary() {
					return this.#salary;
				}

				setSalary(salary) {
					this.#salary = salary;
				}
			}

			const w = new Worker('张三', 20, 998);
			// console.log(w.name);//张三
			// console.log(w.age);//20
			// console.log(w.#salary); //私有属性不能访问

			// let s = w.getSalary();
			// console.log(s);

			w.name = '李四';
			w.age = 40;
			console.log(w.name); //李四
			console.log(w.age); //40
			w.setSalary(2000);
			let s = w.getSalary();
			console.log(s);
		</script>
	</body>
</html>
